﻿using EntityFramework.Entity.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YouTravel.DomainModels;

namespace Repositories.Configuration
{
    public class ContractMap : EntityConfigurationBase<Contract>
    {
        public ContractMap()
        {
            this.Property(p => p.Name).HasMaxLength(50).IsRequired();
            this.Property(p => p.Code).HasMaxLength(21).IsRequired();


            this.HasRequired(p => p.Creater).WithMany().HasForeignKey(f => f.CreaterId);
            this.HasRequired(p => p.Updater).WithMany().HasForeignKey(f => f.UpdaterId);
            this.HasMany(p => p.Attachments).WithOptional();

            this.HasOptional(p => p.SellerSupplier).WithMany().HasForeignKey(f => f.SellerSupplierId);
            this.HasOptional(p => p.Branch).WithMany().HasForeignKey(f => f.BranchId);
            this.HasOptional(p => p.Special).WithMany().HasForeignKey(f => f.SpecialId);
        }
    }
}
